/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EACenter.java
 *
 * Created on 2009-3-7, 13:58:20
 */

package eac.view;
import eac.model.ComponentModel;
import eac.model.ValueModel;
import eac.ucm.RefreshTable;
import eac.ucm.ShowPersonalInfo;
import eac.ucm.DeleteValue;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import medium.*;
/**
 *
 * @author Vitamin
 */
public class EACenter extends javax.swing.JFrame{

    private ComponentModel component;
    private ValueModel value;
    private static EACenter local;
    private RefreshTable refresher;
    private ShowPersonalInfo show;
    private AddRecordPanel addRecord;
    private DeleteValue deleteRecord;
    private AddCoursePanel addCourse;
    private MsgSender sender;
    public EACenter() {
        initComponents();
        component=new ComponentModel();
        value=new ValueModel();
        local=this;

        addWindowListener(new WindowAdapter() {
//        @Override
//        public void windowClosing( WindowEvent e )
//        {
//            System.exit( 0 ); }
            @Override
            public void windowClosed(WindowEvent e) {
                MsgSender.getInstance().toExit();
                try{
                Thread.sleep(1);
            }catch(Exception et)
            {
                et.printStackTrace();
            }
            System.exit(0);
            }
 } );
    }

    public static EACenter getInstance()
    {
        if(local==null)
        {
            local=new EACenter();
            local.setVisible(true);
        }
        return local;
    }


    public ComponentModel getComponentModel()
    {
        component.setAchievement(table1);
        component.setId(id);
        component.setLbphoto(lbphoto);
        component.setLbcid(lbcid);
        component.setLbcollege(lbcollege);
        component.setLbgroup(lbgroup);
        component.setLbname(lbname);
        component.setCourse(tcourse);
        component.setResponse(response);
        component.setTid(tid);
        component.setTresponse(tresponse);
        component.setTlbcid(tlbcid);
        component.setTlbcollege(tlbcollege);
        component.setTlbgroup(tlbgroup);
        component.setTlbname(tlbname);
        component.setTlbphoto(tlbphoto);

        return component;
    }


    public ValueModel getValueModel()
    {
        value.setId(id.getText());
        value.setResponse(response.getText());
        value.setTid(tid.getText());

        return value;
    }



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu3 = new javax.swing.JMenu();
        jMenu4 = new javax.swing.JMenu();
        mainPanel = new javax.swing.JTabbedPane();
        stPanel = new javax.swing.JPanel();
        jSplitPane1 = new javax.swing.JSplitPane();
        jSplitPane2 = new javax.swing.JSplitPane();
        jPanel1 = new javax.swing.JPanel();
        save = new javax.swing.JButton();
        cancel = new javax.swing.JButton();
        id = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        search = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        lbphoto = new javax.swing.JLabel();
        lbname = new javax.swing.JLabel();
        lbcid = new javax.swing.JLabel();
        lbgroup = new javax.swing.JLabel();
        lbcollege = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jSeparator3 = new javax.swing.JSeparator();
        jSeparator4 = new javax.swing.JSeparator();
        jSplitPane3 = new javax.swing.JSplitPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        table = new javax.swing.JTabbedPane();
        achievement = new javax.swing.JScrollPane();
        table1 = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        jPanel3 = new javax.swing.JPanel();
        jSplitPane4 = new javax.swing.JSplitPane();
        jToolBar1 = new javax.swing.JToolBar();
        jSeparator5 = new javax.swing.JToolBar.Separator();
        add = new javax.swing.JButton();
        jSeparator6 = new javax.swing.JToolBar.Separator();
        delete = new javax.swing.JButton();
        jSeparator7 = new javax.swing.JToolBar.Separator();
        refresh = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        response = new javax.swing.JTextArea();
        tPanel = new javax.swing.JPanel();
        jSplitPane5 = new javax.swing.JSplitPane();
        jSplitPane6 = new javax.swing.JSplitPane();
        jScrollPane4 = new javax.swing.JScrollPane();
        table3 = new javax.swing.JTabbedPane();
        coursePanel = new javax.swing.JScrollPane();
        tcourse = new javax.swing.JTable();
        jSplitPane8 = new javax.swing.JSplitPane();
        jToolBar2 = new javax.swing.JToolBar();
        jSeparator12 = new javax.swing.JToolBar.Separator();
        tadd = new javax.swing.JButton();
        jSeparator13 = new javax.swing.JToolBar.Separator();
        tdelete = new javax.swing.JButton();
        jSeparator14 = new javax.swing.JToolBar.Separator();
        trefresh = new javax.swing.JButton();
        jScrollPane5 = new javax.swing.JScrollPane();
        tresponse = new javax.swing.JTextArea();
        jSplitPane7 = new javax.swing.JSplitPane();
        jPanel4 = new javax.swing.JPanel();
        tsave = new javax.swing.JButton();
        tcancel = new javax.swing.JButton();
        tid = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        tsearch = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        tlbphoto = new javax.swing.JLabel();
        tlbname = new javax.swing.JLabel();
        tlbcid = new javax.swing.JLabel();
        tlbgroup = new javax.swing.JLabel();
        tlbcollege = new javax.swing.JLabel();
        jSeparator8 = new javax.swing.JSeparator();
        jSeparator9 = new javax.swing.JSeparator();
        jSeparator10 = new javax.swing.JSeparator();
        jSeparator11 = new javax.swing.JSeparator();

        jMenu3.setText("File");
        jMenuBar2.add(jMenu3);

        jMenu4.setText("Edit");
        jMenuBar2.add(jMenu4);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Education Administration Center");
        setResizable(false);
        getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));

        mainPanel.setBackground(new java.awt.Color(153, 153, 153));
        mainPanel.setTabPlacement(javax.swing.JTabbedPane.LEFT);
        mainPanel.setAutoscrolls(true);
        mainPanel.setFont(new java.awt.Font("Arial", 1, 14));

        stPanel.setFont(new java.awt.Font("Arial", 1, 12));

        jSplitPane1.setDividerLocation(290);
        jSplitPane1.setDividerSize(1);

        jSplitPane2.setDividerLocation(260);
        jSplitPane2.setDividerSize(1);
        jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Student Panel", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        save.setFont(new java.awt.Font("Arial", 1, 12));
        save.setText("Save");

        cancel.setFont(new java.awt.Font("Arial", 1, 12));
        cancel.setText("Cancel");
        cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelActionPerformed(evt);
            }
        });

        id.setFont(new java.awt.Font("Arial", 0, 12));
        id.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                idActionPerformed(evt);
            }
        });
        id.addInputMethodListener(new java.awt.event.InputMethodListener() {
            public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
            }
            public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
                idInputMethodTextChanged(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel1.setText("ID: ");

        search.setFont(new java.awt.Font("Arial", 1, 12));
        search.setText("Search");
        search.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(search, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(save, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancel, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(id))
                .addContainerGap(23, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(id, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(search)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 135, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(save)
                    .addComponent(cancel))
                .addContainerGap())
        );

        jSplitPane2.setTopComponent(jPanel1);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Personal Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        lbphoto.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        lbname.setText("name");

        lbcid.setText("cid");

        lbgroup.setText("group");

        lbcollege.setText("college");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jSeparator3)
                        .addComponent(lbcid, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jSeparator4)
                        .addComponent(lbname, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lbgroup, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lbcollege, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(lbphoto, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(47, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbphoto, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lbname)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(2, 2, 2)
                .addComponent(lbcid)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbgroup)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbcollege)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(26, Short.MAX_VALUE))
        );

        jSplitPane2.setRightComponent(jPanel2);

        jSplitPane1.setLeftComponent(jSplitPane2);

        jSplitPane3.setDividerLocation(560);
        jSplitPane3.setDividerSize(1);
        jSplitPane3.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        table.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Relevant Data", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N
        table.setFont(new java.awt.Font("Arial", 1, 12));

        table1.setFont(new java.awt.Font("Arial", 0, 12));
        table1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Course ID", "Teacher ID", "Marks", "Failed", "Update Date"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        achievement.setViewportView(table1);

        table.addTab("Achievement Display", achievement);

        jScrollPane1.setViewportView(table);

        jSplitPane3.setTopComponent(jScrollPane1);

        jScrollPane2.setBorder(null);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "System Response", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N
        jPanel3.setPreferredSize(new java.awt.Dimension(100, 120));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        jScrollPane2.setViewportView(jPanel3);

        jSplitPane3.setRightComponent(jScrollPane2);

        jSplitPane4.setDividerLocation(30);
        jSplitPane4.setDividerSize(1);
        jSplitPane4.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jToolBar1.setRollover(true);
        jToolBar1.setBorderPainted(false);
        jToolBar1.add(jSeparator5);

        add.setFont(new java.awt.Font("Arial", 1, 12));
        add.setForeground(new java.awt.Color(0, 204, 102));
        add.setText("+ Add Record");
        add.setFocusable(false);
        add.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        add.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        add.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addActionPerformed(evt);
            }
        });
        jToolBar1.add(add);
        jToolBar1.add(jSeparator6);

        delete.setFont(new java.awt.Font("Arial", 1, 12));
        delete.setForeground(new java.awt.Color(255, 0, 51));
        delete.setText("- Delete Record");
        delete.setFocusable(false);
        delete.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        delete.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        delete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteActionPerformed(evt);
            }
        });
        jToolBar1.add(delete);
        jToolBar1.add(jSeparator7);

        refresh.setFont(new java.awt.Font("Arial", 1, 12));
        refresh.setForeground(new java.awt.Color(0, 51, 204));
        refresh.setText(" Refresh");
        refresh.setFocusable(false);
        refresh.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        refresh.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        refresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshActionPerformed(evt);
            }
        });
        jToolBar1.add(refresh);

        jSplitPane4.setTopComponent(jToolBar1);

        jScrollPane3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "System Response", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        response.setColumns(20);
        response.setEditable(false);
        response.setFont(new java.awt.Font("Arial", 1, 12));
        response.setRows(20);
        jScrollPane3.setViewportView(response);

        jSplitPane4.setRightComponent(jScrollPane3);

        jSplitPane3.setRightComponent(jSplitPane4);

        jSplitPane1.setRightComponent(jSplitPane3);

        javax.swing.GroupLayout stPanelLayout = new javax.swing.GroupLayout(stPanel);
        stPanel.setLayout(stPanelLayout);
        stPanelLayout.setHorizontalGroup(
            stPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 922, Short.MAX_VALUE)
        );
        stPanelLayout.setVerticalGroup(
            stPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 715, Short.MAX_VALUE)
        );

        mainPanel.addTab("Student", stPanel);

        jSplitPane5.setDividerLocation(290);
        jSplitPane5.setDividerSize(1);

        jSplitPane6.setDividerLocation(560);
        jSplitPane6.setDividerSize(1);
        jSplitPane6.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        table3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Relevant Data", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N
        table3.setFont(new java.awt.Font("Arial", 1, 12));

        tcourse.setFont(new java.awt.Font("Arial", 0, 12));
        tcourse.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Course ID", "Course Title", "Credit Hour", "Description", "College"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, true, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        coursePanel.setViewportView(tcourse);

        table3.addTab("Course Display", coursePanel);

        jScrollPane4.setViewportView(table3);

        jSplitPane6.setTopComponent(jScrollPane4);

        jSplitPane8.setDividerLocation(30);
        jSplitPane8.setDividerSize(1);
        jSplitPane8.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jToolBar2.setRollover(true);
        jToolBar2.setBorderPainted(false);
        jToolBar2.add(jSeparator12);

        tadd.setFont(new java.awt.Font("Arial", 1, 12));
        tadd.setForeground(new java.awt.Color(0, 204, 102));
        tadd.setText("+ Add Record");
        tadd.setFocusable(false);
        tadd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        tadd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tadd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                taddActionPerformed(evt);
            }
        });
        jToolBar2.add(tadd);
        jToolBar2.add(jSeparator13);

        tdelete.setFont(new java.awt.Font("Arial", 1, 12));
        tdelete.setForeground(new java.awt.Color(255, 0, 51));
        tdelete.setText("- Delete Record");
        tdelete.setFocusable(false);
        tdelete.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        tdelete.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tdelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tdeleteActionPerformed(evt);
            }
        });
        jToolBar2.add(tdelete);
        jToolBar2.add(jSeparator14);

        trefresh.setFont(new java.awt.Font("Arial", 1, 12));
        trefresh.setForeground(new java.awt.Color(0, 51, 204));
        trefresh.setText(" Refresh");
        trefresh.setFocusable(false);
        trefresh.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        trefresh.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        trefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                trefreshActionPerformed(evt);
            }
        });
        jToolBar2.add(trefresh);

        jSplitPane8.setTopComponent(jToolBar2);

        jScrollPane5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "System Response", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        tresponse.setColumns(20);
        tresponse.setEditable(false);
        tresponse.setFont(new java.awt.Font("Arial", 1, 12));
        tresponse.setRows(20);
        jScrollPane5.setViewportView(tresponse);

        jSplitPane8.setRightComponent(jScrollPane5);

        jSplitPane6.setRightComponent(jSplitPane8);

        jSplitPane5.setRightComponent(jSplitPane6);

        jSplitPane7.setDividerLocation(260);
        jSplitPane7.setDividerSize(1);
        jSplitPane7.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Teacher Panel", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        tsave.setFont(new java.awt.Font("Arial", 1, 12));
        tsave.setText("Save");

        tcancel.setFont(new java.awt.Font("Arial", 1, 12));
        tcancel.setText("Cancel");

        tid.setFont(new java.awt.Font("Arial", 0, 12));
        tid.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tidActionPerformed(evt);
            }
        });
        tid.addInputMethodListener(new java.awt.event.InputMethodListener() {
            public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
            }
            public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
                tidInputMethodTextChanged(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Arial", 0, 12));
        jLabel2.setText("ID: ");

        tsearch.setFont(new java.awt.Font("Arial", 1, 12));
        tsearch.setText("Search");
        tsearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tsearchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(tsearch, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(tsave, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tcancel, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(tid))
                .addContainerGap(23, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(tid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tsearch)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 135, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tsave)
                    .addComponent(tcancel))
                .addContainerGap())
        );

        jSplitPane7.setTopComponent(jPanel4);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Personal Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        tlbphoto.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        tlbname.setText("name");

        tlbcid.setText("cid");

        tlbgroup.setText("group");

        tlbcollege.setText("college");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jSeparator10)
                        .addComponent(tlbcid, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                        .addComponent(jSeparator8, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jSeparator9, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jSeparator11)
                        .addComponent(tlbname, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(tlbgroup, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(tlbcollege, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(tlbphoto, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(47, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tlbphoto, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(tlbname)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator8, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(2, 2, 2)
                .addComponent(tlbcid)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator9, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tlbgroup)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator10, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tlbcollege)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator11, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(26, Short.MAX_VALUE))
        );

        jSplitPane7.setRightComponent(jPanel5);

        jSplitPane5.setLeftComponent(jSplitPane7);

        javax.swing.GroupLayout tPanelLayout = new javax.swing.GroupLayout(tPanel);
        tPanel.setLayout(tPanelLayout);
        tPanelLayout.setHorizontalGroup(
            tPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 922, Short.MAX_VALUE)
        );
        tPanelLayout.setVerticalGroup(
            tPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 715, Short.MAX_VALUE)
        );

        mainPanel.addTab("Teacher", tPanel);

        getContentPane().add(mainPanel);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void searchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchActionPerformed

        show=new ShowPersonalInfo();
        show.setStudentValue();
        MsgSender.getInstance().toEACShowAchievementInfo();

}//GEN-LAST:event_searchActionPerformed

    private void idInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_idInputMethodTextChanged

}//GEN-LAST:event_idInputMethodTextChanged

    private void idActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idActionPerformed

}//GEN-LAST:event_idActionPerformed

    private void addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addActionPerformed
        addRecord=new AddRecordPanel();
        addRecord.setVisible(true);
 
    }//GEN-LAST:event_addActionPerformed

    private void refreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshActionPerformed

        RefreshTable.getInstance().initStudentTable();
        MsgSender.getInstance().toEACShowAchievementInfo();

    }//GEN-LAST:event_refreshActionPerformed

    private void deleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteActionPerformed

        DeleteValue.getInstance().deleteStudentValue();

        
    }//GEN-LAST:event_deleteActionPerformed

    private void tidActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tidActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_tidActionPerformed

    private void tidInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_tidInputMethodTextChanged
        // TODO add your handling code here:
}//GEN-LAST:event_tidInputMethodTextChanged

    private void tsearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tsearchActionPerformed

        show=new ShowPersonalInfo();
        show.setTeacherValue();
        MsgSender.getInstance().toEACShowCourseInfo();
}//GEN-LAST:event_tsearchActionPerformed

    private void taddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_taddActionPerformed
        addCourse=new AddCoursePanel();
        addCourse.setVisible(true);
}//GEN-LAST:event_taddActionPerformed

    private void tdeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tdeleteActionPerformed
        DeleteValue.getInstance().deleteTeacherValue();
}//GEN-LAST:event_tdeleteActionPerformed

    private void trefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_trefreshActionPerformed
//        refresher=new RefreshTable();
//        refresher.showCourse();
        RefreshTable.getInstance().initTeacherTable();
        MsgSender.getInstance().toEACShowCourseInfo();
}//GEN-LAST:event_trefreshActionPerformed

    private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
        try{
        MsgSender.getInstance().toExit();
        MsgSender.getInstance().getSocketModel().getSocket().close();
        MsgSender.getInstance().getSocketModel().getReader().close();
        MsgSender.getInstance().getSocketModel().getSender().close();
        }catch(Exception e)
        {
            e.printStackTrace();
        }
    }//GEN-LAST:event_cancelActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new EACenter().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane achievement;
    private javax.swing.JButton add;
    private javax.swing.JButton cancel;
    private javax.swing.JScrollPane coursePanel;
    private javax.swing.JButton delete;
    private javax.swing.JTextField id;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator10;
    private javax.swing.JSeparator jSeparator11;
    private javax.swing.JToolBar.Separator jSeparator12;
    private javax.swing.JToolBar.Separator jSeparator13;
    private javax.swing.JToolBar.Separator jSeparator14;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JToolBar.Separator jSeparator5;
    private javax.swing.JToolBar.Separator jSeparator6;
    private javax.swing.JToolBar.Separator jSeparator7;
    private javax.swing.JSeparator jSeparator8;
    private javax.swing.JSeparator jSeparator9;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JSplitPane jSplitPane2;
    private javax.swing.JSplitPane jSplitPane3;
    private javax.swing.JSplitPane jSplitPane4;
    private javax.swing.JSplitPane jSplitPane5;
    private javax.swing.JSplitPane jSplitPane6;
    private javax.swing.JSplitPane jSplitPane7;
    private javax.swing.JSplitPane jSplitPane8;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JToolBar jToolBar2;
    private javax.swing.JLabel lbcid;
    private javax.swing.JLabel lbcollege;
    private javax.swing.JLabel lbgroup;
    private javax.swing.JLabel lbname;
    private javax.swing.JLabel lbphoto;
    private javax.swing.JTabbedPane mainPanel;
    private javax.swing.JButton refresh;
    private javax.swing.JTextArea response;
    private javax.swing.JButton save;
    private javax.swing.JButton search;
    private javax.swing.JPanel stPanel;
    private javax.swing.JPanel tPanel;
    private javax.swing.JTabbedPane table;
    private javax.swing.JTable table1;
    private javax.swing.JTabbedPane table3;
    private javax.swing.JButton tadd;
    private javax.swing.JButton tcancel;
    private javax.swing.JTable tcourse;
    private javax.swing.JButton tdelete;
    private javax.swing.JTextField tid;
    private javax.swing.JLabel tlbcid;
    private javax.swing.JLabel tlbcollege;
    private javax.swing.JLabel tlbgroup;
    private javax.swing.JLabel tlbname;
    private javax.swing.JLabel tlbphoto;
    private javax.swing.JButton trefresh;
    private javax.swing.JTextArea tresponse;
    private javax.swing.JButton tsave;
    private javax.swing.JButton tsearch;
    // End of variables declaration//GEN-END:variables

}
